﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BSCMFF.Core.DataAccessLayer
{
    public partial class Personal_KPI
    {
        public string Percentage 
        { 
            get
            {
                string p;
                if (this.StartValue != null && this.TargetValue != null)
                {
                    double start = (double)this.StartValue;
                    double target = (double)this.TargetValue;



                    if (start != target)
                    {
                        double current = this.CurrentValue == null ? start : (double)this.CurrentValue;
                        p = ((int)(((current - start) * 100 / (target - start)))).ToString();
                    }
                    else
                    {
                        p = "0";
                    }
                    //else
                    //{
                    //    double current = this.CurrentValue == null ? target : (double)this.CurrentValue;
                    //    p = ((int)(((target - current) / (target - start)) * 100)).ToString();
                    //}
                }
                else
                {
                    p = "0";
                }

                return p + "%";
            }
            //set
            //{

            //}
        }
    }
}
